﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="MovieList.aspx.cs" Inherits="MovieList" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    


    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>" 
        
        
        SelectCommand="SELECT Movie.Title, Movie.Description, Movie.Length, Movie.Director, Category.Name, Movie.MovieID FROM Movie INNER JOIN CategoryMovie ON Movie.MovieID = CategoryMovie.MovieID INNER JOIN Category ON CategoryMovie.CategoryID = Category.CategoryID WHERE (Category.CategoryID = @CategoryID)">
        <SelectParameters>
            <asp:QueryStringParameter Name="CategoryID" QueryStringField="CategoryId" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:GridView ID="GridView1" runat="server" 
        AutoGenerateColumns="False" DataSourceID="SqlDataSource1" 
   AllowPaging="True" DataKeyNames="MovieID" >
        <Columns>
            <asp:HyperLinkField DataNavigateUrlFields="MovieID" 
                DataNavigateUrlFormatString="~/Movie.aspx?MovieId={0}" DataTextField="Title" 
                HeaderText="Title" SortExpression="Title" />
            <asp:BoundField DataField="Description" HeaderText="Description" 
                SortExpression="Description" />
            <asp:BoundField DataField="Length" HeaderText="Length" 
                SortExpression="Length" />
            <asp:BoundField DataField="Director" HeaderText="Director" 
                SortExpression="Director" />
            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
        </Columns>
        <EmptyDataTemplate>
            Sorry no Movie available for the selected Category!
        </EmptyDataTemplate>
    </asp:GridView>
    


</asp:Content>

